Skip to content

feat: improve default slugify utility by triming whitespace first#14421

Merged
paulpopus merged 2 commits intopayloadcms:mainfrom
MichalKormanik:feat/trim-slugs
Apr 2, 2026
Merged

feat: improve default slugify utility by triming whitespace first#14421
paulpopus merged 2 commits intopayloadcms:mainfrom
MichalKormanik:feat/trim-slugs

Conversation

@MichalKormanik
Copy link
Copy Markdown
Contributor

@MichalKormanik MichalKormanik commented Oct 30, 2025

Currently, when you are creating slugs and leave spaces on beggining or the end, they will be replaced with hyphen, this enhancement avoids trims unwanted spaces first.

What?

Utilities for creating slugs from titles

Why?

Badly created slug with hyphen in the end, when user added title with space.

How?

Adding simple trim() function before replacing spaces with hyphens

Currently, when you are creating slugs and leave spaces on beggining or the end, they will be replaced with hyphen, this enhancement avoids trims unwanted spaces first.
@MichalKormanik MichalKormanik changed the title fix(slugs): improve creating slugs by triming first fix(templates): improve creating slugs by triming first Oct 30, 2025
@github-actions github-actions Bot added the stale label Dec 23, 2025
@github-actions github-actions Bot removed the stale label Jan 23, 2026
@MichalKormanik MichalKormanik changed the title fix(templates): improve creating slugs by triming first fix(templates): improve creating slugs by triming first Feb 3, 2026
@github-actions github-actions Bot added the stale label Mar 6, 2026
@github-actions github-actions Bot removed the stale label Apr 2, 2026
@paulpopus paulpopus changed the title fix(templates): improve creating slugs by triming first fix: improve default slugify utility by triming whitespace first Apr 2, 2026
@paulpopus paulpopus changed the title fix: improve default slugify utility by triming whitespace first feat: improve default slugify utility by triming whitespace first Apr 2, 2026
@paulpopus paulpopus enabled auto-merge (squash) April 2, 2026 17:19
@paulpopus paulpopus merged commit fdaa051 into payloadcms:main Apr 2, 2026
159 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 8, 2026

🚀 This is included in version v3.82.0

milamer pushed a commit to milamer/payload that referenced this pull request Apr 20, 2026
…yloadcms#14421)

Currently, when you are creating slugs and leave spaces on beggining or
the end, they will be replaced with hyphen, this enhancement avoids
trims unwanted spaces first.

### What?
Utilities for creating slugs from titles

### Why?
Badly created slug with hyphen in the end, when user added title with
space.

### How?
Adding simple `trim()` function before replacing spaces with hyphens

Co-authored-by: Paul Popus <paul@payloadcms.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants